package com.wlyuan.open.domain.source.assembler;

import com.wlyuan.basic.dto.carrier.CarrierRewriteDTO;
import com.wlyuan.core.domain.MappingIds;
import com.wlyuan.core.marker.NamedStatus;
import com.wlyuan.open.domain.source.utils.MappingOrder;
import com.wlyuan.open.dto.OpenCarrierSyncDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author yuanzheng
 */
public class CarrierAssembler {

    private static final Assembler ASSEMBLER = Mappers.getMapper(Assembler.class);

    @Mapper(uses = {
            MappingIds.class,
            MappingOrder.class,
    }, imports = {
            NamedStatus.class,
    })
    public interface Assembler {

        @Mappings({
                @Mapping(source = "personal", target = "subjectType")
        })
        CarrierRewriteDTO assemble(OpenCarrierSyncDTO source);

    }

    public static CarrierRewriteDTO assemble(OpenCarrierSyncDTO source) {
        return ASSEMBLER.assemble(source);
    }

}
